export default function scale(
  outerWidth,
  outerHeight,
  originWidth,
  originHeight,
  size = "cover"
) {
  let res = {
    vertical: false,
    width: 0,
    height: 0
  };
  if (outerWidth / outerHeight > originWidth / originHeight) {
    if (size == "cover") {
      res.width = outerWidth;
      res.height = (originHeight / originWidth) * outerWidth;
      res.vertical = true;
    } else {
      res.height = outerHeight;
      res.width = (originWidth / originHeight) * outerHeight;
      res.vertical = false;
    }
  } else {
    if (size == "cover") {
      res.height = outerHeight;
      res.width = (originWidth / originHeight) * outerHeight;
      res.vertical = false;
    } else {
      res.width = outerWidth;
      res.height = (originHeight / originWidth) * outerWidth;
      res.vertical = true;
    }
  }

  return res;
}
